package com.piece.module.generator.repository.impl;

import com.piece.core.jpa.repository.BaseRepository;
import com.piece.module.generator.model.GenTable;
import com.piece.module.generator.repository.GenTableRepository;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class GenTableRepositoryImpl extends BaseRepository<GenTable, String> implements GenTableRepository {

    @Override
    public GenTable findByTableName(String dbKey, String tableName) {
        Map<String, Object> params = new HashMap<>();
        params.put("dbKey", dbKey);
        params.put("tableName", tableName);
        List<GenTable> tables = this.findByCondition(params, null);
        return (null == tables || tables.size() == 0) ? null : tables.get(0);
    }
}
